package cn.tedu.egmvc1.controller;

import cn.tedu.egmvc1.mapper.AddressMapper;
import cn.tedu.egmvc1.pojo.entity.Address;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping(value = "/address/")
public class AddressController {
    @Autowired
    private AddressMapper addressMapper;
    @RequestMapping(value = "insert")
    public String insertAddress(Address address){
        addressMapper.insertAddress(address);
        return "添加成功";
    }

    @RequestMapping(value = "select")
    public List<Address> addressList(){
        return addressMapper.selectAddress();
    }

    @RequestMapping(value = "delete")
    public String deleteAddress(int id){
        addressMapper.deleteAddress(id);
        return "删除成功";
    }

    @RequestMapping(value = "update")
    public String updateAddress(Address address){
        addressMapper.updataAddress(address);
        return "修改成功";
    }
}
